import { reqGetGoodDetailInfoData } from '@/api'

const state = {
  // 存储商品详情数据
  goodDetailInfo: {},
}
const actions = {
  // 发送请求获取数据,
  async getGoodDetailInfoData({ commit }, id) {
    const result = await reqGetGoodDetailInfoData(id)
    if (result.code === 200) {
      // 如果获取数据成功就
      commit('SAVE_GOOD_DETAIL_INFO_DATA', result.data)
    } else {
      console.log(result.message)
    }
  },
}
const mutations = {
  // 1.将获取的详情数据存储起来
  SAVE_GOOD_DETAIL_INFO_DATA(state, goodDetailInfo) {
    state.goodDetailInfo = goodDetailInfo
  },
}
const getters = {}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
}
